//          https://www.nowcoder.com/practice/a2be806a0e5747a088670f5dc62cfa1e





#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> dp(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (i == 0)
            dp[0] = a[0];
        else if (i == 1)
            dp[1] = max(a[0], a[1]);
        else
        {
            dp[i] = max(a[i] + dp[i - 2], dp[i - 1]);
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}
